package com.ty.skysystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ty.common.utils.PageUtils;
import com.ty.common.utils.Query;
import com.ty.skysystem.dao.UserDao;
import com.ty.skysystem.entity.UserEntity;
import com.ty.skysystem.service.UserService;
import java.util.Map;
import org.springframework.stereotype.Service;

@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {

  @Override
  public PageUtils queryPage(Map<String, Object> params) {
    IPage<UserEntity> page =
        this.page(new Query<UserEntity>().getPage(params), new QueryWrapper<UserEntity>());

    return new PageUtils(page);
  }

  @Override
  public UserEntity login(String username, String password) {
    QueryWrapper<UserEntity> wrapper = new QueryWrapper<>();
    wrapper.eq("user_name", username).eq("password", password);
    return this.baseMapper.selectOne(wrapper);
  }
}
